stage.set_background("schoolentrance")
stage.wait(2)
stage.create_grid_overlay(50, "blue")
stage.set_background_color("azure")
emma = codesters.Sprite("person1")
emma.set_size(0.5)
michael = codesters.Sprite("person2")
michael.set_size(0.5)
emma_x = random.randint(-230,230)
emma_y = random.randint(-230,230)
emma.go_to(emma_x, emma_y)
michael_x = random.randint(-230,230)
michael_y = random.randint(-230,230)
michael.go_to(michael_x, michael_y)
delta_x = emma_x - michael_x
delta_y = emma_y - michael_y
distance = math.sqrt((delta_x**2) + (delta_y**2))
if distance == "yes":
# add your code here
emma.say("I am a sprite.")
t = codesters.Teacher()
try:
params = t.find_block('if')
tval1 = params[0][1]
except:
tval1 = "DNE"
t1 = TestObjective()
t1.add_success('<=' in tval1, "Great Job!")
t1.add_failure('==' in tval1, "Did you change the == to <=?")
t1.add_failure('>' in tval1 or '>=' in tval1, "You are using a > (greater than) symbol instead of a < (less than) symbol!")
t1.add_creative('<=' not in tval1 and '<' in tval1 and '=' not in tval1, "You used < That works too (but it will exclude 200!)")
t3 = TestObjective()
t3.add_success('200' in tval1, "Great job!")
t3.add_failure('"yes"' in tval1, 'Did you change "yes" to 200?')
t3.add_failure('"200"' in tval1, "Whoops! You put the 200 in quotes!")
t3.add_failure(tval1 == "DNE", "Did you delete the if statement?")
tester = TestManager()
tester.add_test_list([t1, t3])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)